package com.scs.application.modules.wm.controller;

import com.scs.application.core.mvc.controller.CrudController;
import com.scs.application.modules.sys.model.RestResult;
import com.scs.application.modules.wm.dto.ProcessDTO;
import com.scs.application.modules.wm.entity.StockProcess;
import com.scs.application.modules.wm.service.StockProcessService;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 */
@RestController
@RequestMapping("/wm/stock_process")
public class StockProcessController extends CrudController<StockProcessService, StockProcess>{

    @PostMapping("/process")
    synchronized  public RestResult process(@RequestBody ProcessDTO stockProcess) {
        service.process(stockProcess);
        return RestResult.ok("加工成功", stockProcess);
    }

    @PostMapping("/submit")
    synchronized public RestResult submit(@RequestBody StockProcess stockProcess) {
        return RestResult.ok("提交成功", service.submit(stockProcess));
    }

    /**
    * @Description：提交并 上架
    */
    @PostMapping("/submitUp")
    synchronized public RestResult submitUp(@RequestBody StockProcess stockProcess) {
        return service.submitUp(stockProcess);
    }

    @PostMapping("/un_submit")
    synchronized public RestResult unSubmit(@RequestBody StockProcess stockProcess) {
        service.unSubmit(stockProcess);
        return RestResult.ok("撤销提交成功", stockProcess);
    }

    @PostMapping("/un_process")
    synchronized public RestResult unProcess(@RequestBody StockProcess stockProcess) {
        service.unProcess(stockProcess);
        return RestResult.ok("撤销加工成功", stockProcess);
    }

    @GetMapping("/barCodeScan")
    synchronized public RestResult barCodeScan(@RequestParam("sn") String sn, @RequestParam("processType") Integer processType) {
        return RestResult.ok("获取成功", service.barCodeScan(sn, processType));
    }
}
